package net.freebytes.es.common.util;

import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;

/**
 * 增强复合查询
 * <p>
 * 1. 过滤空查询
 *
 * @author 千里明月
 * @date 2021/11/16
 **/
public class ExBoolQueryBuilders extends BoolQueryBuilder {
    @Override
    public BoolQueryBuilder must(QueryBuilder queryBuilder) {
        if (queryBuilder == null) {
            return this;
        }
        return super.must(queryBuilder);
    }

    @Override
    public BoolQueryBuilder mustNot(QueryBuilder queryBuilder) {
        if (queryBuilder == null) {
            return this;
        }
        return super.mustNot(queryBuilder);
    }

    @Override
    public BoolQueryBuilder should(QueryBuilder queryBuilder) {
        if (queryBuilder == null) {
            return this;
        }
        return super.should(queryBuilder);

    }
}
